﻿using System;
using System.Linq;


class SelectionSort
{
    static void Main()
    {
        int[] array = { 1, 2, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 3, 4};
        int tempMinElementPosition = new int();
        
        for (int sortedElementNumber = 0; sortedElementNumber < array.Length; sortedElementNumber++)
        {
            int tempMinElement = int.MaxValue;
            bool newElementFount = false;

            for (int counter = sortedElementNumber; counter < array.Length; counter++)
            {
                if (tempMinElement >= array[counter])
                {
                    tempMinElement = array[counter];
                    tempMinElementPosition = counter;
                    newElementFount = true;

                }
            }

            if (newElementFount)
            {
                array[tempMinElementPosition] = array[sortedElementNumber];
                array[sortedElementNumber] = tempMinElement;

            }
            

        }

        Console.WriteLine(string.Join(", ", array));

    }
}
